library(lme4)
library(MuMIn)
library(multcomp)
#Sensitivity tests for Study 1
data1<-read.table(file="S1 Data.txt", header=TRUE, sep="\t")
data_c1 <- transform(data1,cAge=Age-mean(Age),cWords=Words-mean(Words),cPropositions=Propositions-mean(Propositions),cGood=Good-mean(Good),cBad=Bad-mean(Bad),cSurvival=Survival-mean(Survival),cSocial=Social-mean(Social),cMale_Stereo=Male_Stereo-mean(Male_Stereo),cFemale_Stereo=Female_Stereo-mean(Female_Stereo),cEmotional=Emotional-mean(Emotional))
nulla<-glmer(Coder2 ~ (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
gen_onlya<-glmer(Coder2 ~ Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
morala<-glmer(Coder2~ Morality + Generation + (1|Set/Generation/Participant/Vignette),family = binomial, nAGQ = 1, data = data_c1, control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
anova(morala,gen_onlya)
m01a<-glmer(Coder2 ~ cAge + Gender + cWords + cPropositions + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + cEmotional + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m02a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + cEmotional + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m03a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m04a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cBad + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m05a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cBad + cMale_Stereo + cFemale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m06a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cMale_Stereo + cFemale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m07a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cMale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m08a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m09a<-glmer(Coder2 ~ cAge + Gender + cWords + cMale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m10a<-glmer(Coder2 ~ cAge + Gender + cWords + cGood + cMale_Stereo + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m11a<-glmer(Coder2 ~ cAge + Gender + cGood + cMale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m12a<-glmer(Coder2 ~ cAge + cWords + cGood + cMale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m13a<-glmer(Coder2 ~ Gender + cWords + cGood + cMale_Stereo + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c1, family = binomial, nAGQ = 1,control=glmerControl(optimizer="Nelder_Mead",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
model.sel(m01a,m02a,m03a,m04a,m05a,m06a,m07a,m08a,m09a,m10a,m11a,m12a,m13a)
average_modela<-model.avg(m07a,m08a,m06a,m13a)
#
#Sensitivity tests for Study 2
data2<-read.table(file="S2 Data.txt", header=TRUE, sep="\t")
data_c2<- transform(data2,cAge=Age-mean(Age),cWords=Words-mean(Words),cPropositions=Propositions-mean(Propositions),cGood=Good-mean(Good),cBad=Bad-mean(Bad),cSurvival=Survival-mean(Survival),cSocial=Social-mean(Social),cMale_Stereo=Male_Stereo-mean(Male_Stereo),cFemale_Stereo=Female_Stereo-mean(Female_Stereo),cEDA_Score=EDA_Score-mean(EDA_Score),cEmotional=Emotional-mean(Emotional))
nullb<-glmer(Coder2 ~ (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
gen_onlyb<-glmer(Coder2 ~ Generation+ (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m01b<-glmer(Coder2 ~ cAge + Gender + cWords + cPropositions + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
m02b<-glmer(Coder2 ~ Gender + cWords + cPropositions + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m03b<-glmer(Coder2 ~ Gender + cWords + cPropositions + cGood + cBad + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m04b<-glmer(Coder2 ~ Gender + cWords + cPropositions + cGood + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m05b<-glmer(Coder2 ~ Gender + cWords + cPropositions + cGood + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
m06b<-glmer(Coder2 ~ Gender + cWords + cGood + cMale_Stereo + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m07b<-glmer(Coder2 ~ Gender + cWords + cGood + cFemale_Stereo + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m08b<-glmer(Coder2 ~ Gender + cWords + cGood + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m09b<-glmer(Coder2 ~ Gender + cGood + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m10b<-glmer(Coder2 ~ cWords + cGood + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m11b<-glmer(Coder2 ~ Gender + cWords + Emotion + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
m12b<-glmer(Coder2 ~ Gender + cWords + cGood + Generation + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m13b<-glmer(Coder2 ~ Gender + cWords + cGood + Emotion + cEDA_Score + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m14b<-glmer(Coder2 ~ Gender + cWords + cGood + Emotion + Generation + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
model.sel(m01b,m02b,m03b,m04b,m05b,m06b,m07b,m08b,m09b,m10b,m11b,m12b,m13b,m14b)
average_modelb<-model.avg(m07b,m08b,m14b)
H6testb<-glmer(Coder2 ~ Moral.Category + Generation + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
anova(gen_onlyb,H6testb)
H6_mcpb<-glht(H6testb,linfct=mcp(Moral.Category="Tukey"))
H7testb<-glmer(Coder2 ~ Gender + cWords + cGood + cFemale_Stereo + Emotion + Generation + cEmotional + (1|Set/Generation/Participant/Vignette), data = data_c2, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
anova(m07b,H7testb)
#
#Sensitivity tests for SM9
data3<-read.table(file="SM9 Data.txt", header=TRUE, sep="\t")
data_c3 <- transform(data3,cAge=Age-mean(Age),cWords=Words-mean(Words),cPropositions=Propositions-mean(Propositions),cGood=Good-mean(Good),cBad=Bad-mean(Bad),cSurvival=Survival-mean(Survival),cSocial=Social-mean(Social),cMale_Stereo=Male_Stereo-mean(Male_Stereo),cFemale_Stereo=Female_Stereo-mean(Female_Stereo),cEmotional=Emotional-mean(Emotional))
moral_recallc<-glmer(Coder2~ Morality + (1|Set/Participant/Vignette),family = binomial, nAGQ = 1, data = data_c3, control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
null_recallc<-glmer(Coder2 ~ (1|Set/Participant/Vignette), data = data_c3, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
anova(moral_recallc,null_recallc)
data3b<-read.table(file="SM9b Data.txt", header=TRUE, sep="\t")
data_c3b <- transform(data2,cAge=Age-mean(Age),cWords=Words-mean(Words),cPropositions=Propositions-mean(Propositions),cGood=Good-mean(Good),cBad=Bad-mean(Bad),cSurvival=Survival-mean(Survival),cSocial=Social-mean(Social),cMale_Stereo=Male_Stereo-mean(Male_Stereo),cFemale_Stereo=Female_Stereo-mean(Female_Stereo),cEmotional=Emotional-mean(Emotional))
m01c<-glmer(Coder2~ cAge + Gender + cWords + Propositions + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + cEmotional +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m02c<-glmer(Coder2~ cAge + Gender + Propositions + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + cEmotional +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m03c<-glmer(Coder2~ cAge + Gender + cGood + cBad + cSurvival + cSocial + cMale_Stereo + cFemale_Stereo + Emotion + cEmotional +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m04c<-glmer(Coder2~ cAge + Gender + cGood + cBad + cSurvival + cSocial + cFemale_Stereo + Emotion + cEmotional +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m05c<-glmer(Coder2~ cAge + Gender + cGood + cBad + cSurvival + cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m06c<-glmer(Coder2~ cAge + Gender + cGood + cSurvival + cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m07c<-glmer(Coder2~ cAge + cGood + cSurvival + cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa",calc.derivs = FALSE, optCtrl = list(maxfun = 100000)))
m08c<-glmer(Coder2~ cAge + cSurvival + cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m09c<-glmer(Coder2~ cAge + cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m10c<-glmer(Coder2~ cAge + cSocial + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m11c<-glmer(Coder2~ cAge + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m12c<-glmer(Coder2~ cAge + cSocial + cFemale_Stereo +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
m13c<-glmer(Coder2~ cSocial + cFemale_Stereo + Emotion +(1|Set/Participant/Vignette),data = data_c3b, family = binomial, nAGQ = 1,control=glmerControl(optimizer="bobyqa", calc.derivs = FALSE,optCtrl = list(maxfun = 100000)))
model.sel(m01c,m02c,m03c,m04c,m05c,m06c,m07c,m08c,m09c,m10c,m11c,m12c,m13c)
average_modelc<-model.avg(m10c,m09c,m11c,m08c,m07c)